
<cfif session.qcount eq ArrayLen(session.arrsQ) + 1>

	<cfset session.prev = "">
	<cfset session.count = 1>
	<cfset session.hour = #Hour(Now())#>	
	<cfset session.minute = #Minute(Now())#>	
	<cfset session.second = #Second(Now())#>
    	<!--- redirects to next page --->
	<cfheader statuscode="301" statustext="Moved Permanently">
	<cfheader name="Location" value="/ecada/exppageV2.cfm?id=#id#">
	<cfabort>

 </cfif>







<cfquery name = "ww" datasource="exp">
SELECT id, question, istext, likertid, radioid
   FROM question
	  WHERE id=#session.arrsQ[session.qcount]#
</cfquery>







<cfif IsDefined("form.subAns")>	
	<!--- Stores the participants answers for each question --->
	<cfquery datasource="exp">	
		INSERT INTO givesanswerq( participantid, questid, answer )
		   VALUES( #session.pid#, #ww.id#, <cfqueryparam cfsqltype="cf_sql_varchar" value ="#pans#">) 
	</cfquery> 
	

	<!---needed to choose next question --->




    <!--- Goes to next question --->
    <cfset nxtpage = "window.location.href='/ecada/questionnaire.cfm?id=#id#'">
    <cfset session.count = #session.count# + 1>	
    <cfheader statuscode="301" statustext="Moved Permanently">
    <cfheader name="Location" value="/ecada/questionnaire.cfm?id=#id#">

<cfabort>
<cfelse>


<cfinclude template= "/ecada/pheader.cfm">


<cfloop query = "ww">
<cfquery name = "wwe" datasource="exp">
SELECT id, question, istext, likertid, radioid
   FROM question
	  WHERE id=#session.arrsQ[session.qcount]#
</cfquery>

<cfset session.qcount = #session.qcount# + 1 >


<!--- THIS IS WHAT THE PAGE WILL OUTPUT --->
<cfoutput> 
   		
    <table><tr><td>Question:  #wwe.question#</tr></td></table>      
    <form method = "post" id="form1" action = "/ecada/questionnaire.cfm?id=#id#" enctype="multipart/form-data">   
   	

    <input type="text" name="pans" id="pans"  value="" /><br />

</cfloop>

   	<table><tr><td> <input type="submit" value="Next" name="subAns"> </table></tr></td>
    </form>   
    </cfoutput>
</cfif>   
<!--- END OF PAGE OUTPUT --->




